package com.ht.aems.fesservice.job;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2008-7-15
 */

import com.ht.aems.fesservice.RemoteFesServer;
import com.ht.aems.fesservice.Sampler;
import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2008-5-3
 */
public class SampleJob implements Job {
    private static Logger log = Logger.getLogger(SampleJob.class);
    private static boolean isRunning = false;
    private static Sampler sampler = new Sampler();

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        if (isRunning) return;
        try {
            isRunning = true;
            if (RemoteFesServer.getInstance().isPrimeMachine())
                sampler.sample();
        } catch (Exception e) {
            log.warn(e);
            e.printStackTrace();
        } finally {
            isRunning = false;
        }
    }
}